<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>请求列表</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<link href="<?php echo base_url()?>media/css/style.css" type="text/css" rel="stylesheet"/>
	<link href="<?php echo base_url()?>media/css/jquery-ui-1.8.6.custom.css" type="text/css" rel="stylesheet"/>
	<link href="<?php echo base_url()?>media/css/ui.jqgrid.css" type="text/css" rel="stylesheet"/>
	<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/grid.locale-cn.js"></script>
	<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/jquery.jqGrid.min.js"></script>
</head>
<body>
	<div class="form_div">
		<h5>管理员列表</h5>
		<div id="select_frame" class="black_border">
			<div class="select_item" style="width:300px">
				<!--<label>显示</label>
				<select name="requestGroup" style="width:140px" onchange="changeGroup()">>
				</select>-->
                <input type=button value="新建" class="btn_60_24" onclick="javascript:window.location.href='<?=base_url()?>adminWorker/NewWorker';" style="margin:5px; float:right"/>
			</div>

			<div class="clear_both"></div>
		</div>

		<table id="list"></table>

		<div id="pager"></div>
	</div>
</body>
</html>
<script>
jQuery(document).ready(function(){
  $("#list").jqGrid({
    datatype: 'json',
	url:'<?php echo base_url()?>adminWorker/adminRequestData/',
	mtype:'POST',
	height:'auto',
	width:'auto',
	jsonReader: {root:'rows',repeatitems:false},
    colNames:['编号','组员名', '所属组','是否负责人','操作'],
    colModel :[
      {name:'worker_id', index:'worker_id', width:80, sorttype:'int', formatter:formatLink},
      {name:'worker_name', index:'worker_name', width:70, align:'center',formatter:formatLink},
      {name:'group_name', index:'worker_groupid', width:80, align:'center', sorttype:'float',formatter:formatLink},
      {name:'charger_name', index:'is_charger ', width:190, align:'left', sorttype:'float',formatter:formatLink},
	  {name:'delete_worker', index:'worker_id ', width:50, align:'left', sorttype:'float',formatter:formatDelLink}
	  ],
    pager: '#pager',
    rowNum:20,
	sortorder:'desc',
    rowList:[20,30,40],
    viewrecords: true
  });
  function formatLink(cellvalue, options, rowObject)
  {
	return '<a href="<?=base_url()?>adminWorker/NewWorker/?worker_id='+rowObject.worker_id+'">'+cellvalue+'</a>';
  }
  function formatDelLink(cellvalue, options, rowObject)
  {
  	return '<a href="<?=base_url()?>adminWorker/RemoveWorker/?worker_id='+cellvalue+'">删除</a>';
  }
});
function changeGroup()
{
	window.location.href='<?=base_url()?>admin/eventList/?r='+$("select[name='requestGroup']").val();
}
function pad(str, len, pad, dir)
{
	var STR_PAD_LEFT = 1;
	var STR_PAD_RIGHT = 2;
	var STR_PAD_BOTH = 3;

	if (typeof(len) == "undefined") { var len = 0; }
	if (typeof(pad) == "undefined") { var pad = ' '; }
	if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; }

	if (len + 1 >= str.length) {

		switch (dir){

			case STR_PAD_LEFT:
				str = Array(len + 1 - str.length).join(pad) + str;
			break;

			case STR_PAD_BOTH:
				var right = Math.ceil((padlen = len - str.length) / 2);
				var left = padlen - right;
				str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
			break;

			default:
				str = str + Array(len + 1 - str.length).join(pad);
			break;

		} // switch

	}

	return str;

}
</script>
